<div id="main_organizations" class="span-24 last main">
    <div class="span-18">
        <div class="section_organizations_ads">
            <h2><?=$this->translate ( 'Ads list' ).'  -  '.$this->escape( $this->user['username'] );?></h2>
            
            <?php if ($this->ad != null): $auth = Zend_Auth::getInstance (); ?>
                
            <?php foreach ($this->paginator as $key => $val): ?>
                <div class="ad_excerpt">
                   <?php 
                   if ($val['photo'] !== null){
                        echo '<div class="ad_list_image">
                                <a href="/'.$this->lang.'/ad/show/id/'.$this->escape($val['ad_id']).'/'.$this->escape($val['title']).' ">
                                    <img alt="'.$this->escape($val['title']).'" src="/images/uploads/ads/100/'.$this->escape($val['photo']).'" /></a></div>';
                   } else {
                        echo '<div class="ad_list_image">';                 
                            if ($this->lang == 'es') {
                                echo '<a href="/'.$this->lang.'/ad/show/id/'.$this->escape($val['ad_id']).'/'.$this->escape($val['title']).' ">
                                            <img alt="'.$this->escape($val['title']).'" src="/images/sin_imagen.jpg" /></a></div>';
                            } else {
                                echo '<a href="/'.$this->lang.'/ad/show/id/'.$this->escape($val['ad_id']).'/'.$this->escape($val['title']).' ">
                                            <img alt="'.$this->escape($val['title']).'" src="/images/no_image.jpg" /></a></div>';
                            }
                   }
                   // if you are the ad owner or admin, then show edit link
                   if ($auth->hasIdentity()): 
                        if ( ($val['user_owner'] == $auth->getIdentity()->id)  || ($this->userRole == 1) ): ?>
                           <div>
                                <a class="ads_section" href="/<?=$this->lang ?>/ad/orgedit/id/<?=$val['ad_id'] ?>"><?=$this->translate('Edit this ad') ?></a>
                           </div><br />
                   <?php endif;endif; ?>
                       
                  <div class="ad_excerpt_title">
                        <a class="ad_title_link" href="/<?=$this->lang ?>/ad/org/id/<?=$this->escape($val['ad_id']).'/'.$this->escape($val['title']) ?>"><?=$this->escape($val['title']) ?></a>
                  </div>
                 <span class="ad_url"><?=$this->translate('Website').':&nbsp;'?>
                        <a class="ads_section" target="_blank" href="<?=$val['url'] ?>"><?=$val['url'] ?></a>
                      </span>
                       <span class="ad_date"><?=$this->translate('Posted on '). $this->escape(date( $this->translate('l dS \o\f F Y H:i:s'), strtotime($val['date_created']))) ?><?=$this->translate('by user ') ?>
                        <a class="ads_section" href="/<?=$this->lang ?>/ad/listorg/id/<?=$val['user_owner'] ?>"><?=$this->escape($val['username']) ?></a>
                       </span>   
                                                                    
                  <div class="ad_body"><p><?php echo $this->escapeEmail( $this->escape($val['body']) ) ?></p></div>
                </div>    
            <?php endforeach; ?>

            <?php else: ?>
                <div class="no_results">
                <div class="no_results_txt_strong"><?=$this->translate ( 'This user does not have ads yet');?></div>
            </div>
            <?php endif;?>
    
            <?php echo $this->paginationControl($this->paginator, 'Sliding', 'partials/paginator_ads.phtml'); ?>

        </div> <!-- /div ads -->
    </div>

    <div class="span-6 last">
        <div class="profile_icon">
            <a class="profile" id="<?=(preg_match("/profile/", $_SERVER['REQUEST_URI']))?"tab_active":"lala"?>" href="/<?=$this->lang ?>/profile/<?=$this->user['username'] ?>">
            <img alt="<?=$this->translate('Profile') ?>" src="/images/icons/ico_profile.png" class="valign" /><div class="txt_valign"><?=$this->translate('Profile'); ?></div></a>
        </div>
        <div class="clearer"></div>    
        <div class="advertising">
            <!-- BEGIN PARTNER PROGRAM - DO NOT CHANGE THE PARAMETERS OF THE HYPERLINK -->
			<script language="javascript" type="text/javascript" src="http://program.epartner.es/view.asp?ref=570686&site=8346&type=html&hnb=5&js=1"></script>
			<noscript><a href="http://web.epartner.es/click.asp?ref=570686&site=8346&type=b1&bnb=1" target="_blank">
			<img src="http://program.epartner.es/view.asp?ref=570686&site=8346&b=1" border="0"/></a><br /></noscript>
			<!-- END PARTNER PROGRAM -->
        </div>
    </div>

</div> <!-- /main -->